package views
{
	import assists.resource.ResourceLoader;
	import assists.resource.ResourceLoaderData;
	
	import inerface.INavigation;
	
	import main.ViewSubBase;
	
	import panel.viewSpots.navigation.Navigation;
	
	import xmlS.NavigationXMLLoader;
	
	public class NavigationView extends ViewSubBase
	{
		public var navigationID:String = "fahuayuan";
		private var _panel:INavigation;
		private var _xmlLoad:NavigationXMLLoader; 
		public function NavigationView()
		{
			super();
		}
		
		override public function show():void
		{
			_xmlLoad = this.data.xmlLoaderManager.navigationXml;
			_xmlLoad.init(this.data.uri.getNavigation(navigationID),loadRec);
		}
		
		private function loadRec(data:Object):void
		{
			var loadRecList:Array = [];
			loadRecList.push(new ResourceLoaderData(this.data.uri.getNavigationSwf("map",navigationID)));
			
			resourceLoader.load(loadRecList,new Function(),render);
		}
		
		override protected function render():void
		{
			_panel = new Navigation();
			_panel.panelFunc(layout.closeCurrent);
			_panel.init(layout.stage,resourceLoader,lang,this.data.uri);
			_panel.onOpenMusic = openSoundView;
			_panel.onOpenDetail = view.navigationDetail.showComp;
			_panel.load(_xmlLoad.navigationData(this.data.uri.getNavigation(navigationID)),navigationID);
			this.addView(_panel);
			view.guide.upAndDownVisible(false,false);
		}
		
		private function openSoundView(soundUrl:String,desc:String = ""):void
		{
			view.media.soundName = desc;
			view.media.soundUrl = data.uri.getNavigationMp3(soundUrl,navigationID);
			view.media.show();
			_panel.onSoundMedia = view.media.soundMedia;
//			if(desc != "")
//			{
//				view.media.playTextScroll(desc,2,layout.stage.stageWidth * 0.9,layout.stage.stageHeight * 0.3);
//			}
		}
		
		override public function clear():void
		{
			view.guide.upAndDownVisible(true,true);
		}
		
	}
}